package com.ruoyi.project.keshi.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.keshi.domain.SysRegistfee;
import com.ruoyi.project.keshi.service.ISysRegistfeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 挂号费用Controller
 *
 * @author ruoyi
 * @date 2021-09-12
 */
@RestController
@RequestMapping("/keshi/registfee")
public class SysRegistfeeController extends BaseController
{
    @Autowired
    private ISysRegistfeeService sysRegistfeeService;

    /**
     * 查询挂号费用列表
     */
    @PreAuthorize("@ss.hasPermi('keshi:registfee:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysRegistfee sysRegistfee)
    {
        startPage();
        List<SysRegistfee> list = sysRegistfeeService.selectSysRegistfeeList(sysRegistfee);
        return getDataTable(list);
    }

    /**
     * 导出挂号费用列表
     */
    @PreAuthorize("@ss.hasPermi('keshi:registfee:export')")
    @Log(title = "挂号费用", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysRegistfee sysRegistfee)
    {
        List<SysRegistfee> list = sysRegistfeeService.selectSysRegistfeeList(sysRegistfee);
        ExcelUtil<SysRegistfee> util = new ExcelUtil<SysRegistfee>(SysRegistfee.class);
        return util.exportExcel(list, "registfee");
    }

    /**
     * 获取挂号费用详细信息
     */
    @PreAuthorize("@ss.hasPermi('keshi:registfee:query')")
    @GetMapping(value = "/{guaId}")
    public AjaxResult getInfo(@PathVariable("guaId") Long guaId)
    {
        return AjaxResult.success(sysRegistfeeService.selectSysRegistfeeById(guaId));
    }

    /**
     * 新增挂号费用
     */
    @PreAuthorize("@ss.hasPermi('keshi:registfee:add')")
    @Log(title = "挂号费用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysRegistfee sysRegistfee)
    {
        return toAjax(sysRegistfeeService.insertSysRegistfee(sysRegistfee));
    }

    /**
     * 修改挂号费用
     */
    @PreAuthorize("@ss.hasPermi('keshi:registfee:edit')")
    @Log(title = "挂号费用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysRegistfee sysRegistfee)
    {
        return toAjax(sysRegistfeeService.updateSysRegistfee(sysRegistfee));
    }

    /**
     * 删除挂号费用
     */
    @PreAuthorize("@ss.hasPermi('keshi:registfee:remove')")
    @Log(title = "挂号费用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guaIds}")
    public AjaxResult remove(@PathVariable Long[] guaIds)
    {
        return toAjax(sysRegistfeeService.deleteSysRegistfeeByIds(guaIds));
    }
}
